import Vue from 'vue'
import Router from 'vue-router'
import ControlIndex from '@/components/FoodSample'
import KnowledgeIndex from '@/components/FoodKgraph'
import Nav from '@/components/Nav'
import PublicSent from '@/components/PublicSent'
import 'mapbox-gl/dist/mapbox-gl.css'
Vue.use(Router)
const router = new Router({
    /* mode: 'history', */
    routes: [
        {
            path: '/nav',
            name: 'Nav',
            component: Nav
        },

        {
            path: '/control',
            name: 'ControlIndex',
            component: ControlIndex
        },
        {
            path: '/knowledge',
            name: 'KnowledgeIndex',
            component: KnowledgeIndex
        },
        {
            path: '/public',
            name: 'Public',
            component: PublicSent
        },
    ]
})

router.beforeEach((to, from, next) => {
    if (to.path === '/') {
        next({ path: '/public', replace: true })
    } else next()
})

export default router
